import numpy as np
import plotly.io as pio
pio.renderers.default = "notebook"
from src.imgen import ImageGenerator
NUM_QUBITS = 6
NUM_LAYERS = 2
EPOCH_SAMPLE_SIZE = 10**4
BATCH_SAMPLE_SIZE = 10**3
pixel_art = np.array([
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 1, 0, 0],
[0, 0, 1, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0, 1, 0],
[0, 1, 0, 0, 0, 0, 1, 0],
[0, 0, 1, 1, 1, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0]
], dtype=np.float)
imgen = ImageGenerator(
NUM_QUBITS, NUM_LAYERS,
epoch_sample_size=EPOCH_SAMPLE_SIZE, batch_sample_size=BATCH_SAMPLE_SIZE,
enable_remapping=True
)
imgen.load_image(pixel_art, blur_sigma=0.6, show_figure=True)
NUM_EPOCHS = 300
imgen.train(imgen.make_dataset(), NUM_EPOCHS, show_progress=True)
Training epoch 300 of 300:
imgen.plot_output_distribution_history()
imgen.plot_loss_history()
imgen.plot_final_output_distribution(avg_window=5)
imgen.get_final_params(avg_window=10)
array([[[-0.9384098 , -0.5035613 , -0.15809385, -0.28780526,
-0.03601963, 0.02702333],
[ 0.00429374, -0.08270335, 0.22732046, -0.0769777 ,
0.17950357, -0.0446505 ]]], dtype=float32)